/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.passwordstore;

import a03.swing.plaf.A03LookAndFeel;
import java.sql.SQLException;
import javax.swing.LookAndFeel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import org.passwordstore.gui.LoginDialog;
import org.passwordstore.gui.MainFrame;

/**
 *
 * @author thotheolh
 */
public class Main {

    private Main mainInstance = this;
    private static LoginDialog login = null;
    private static String guiConf = "";
    private static boolean isLocked = false;
    private static MainFrame mf = null;

    public Main() {

        doLAF();

        //Do login
        login = new LoginDialog(null, true, mainInstance);
        login.setVisible(true);
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        new Main();
    }

    public void spawnMainWindow() {
        setMf(new MainFrame());
        getMf().setVisible(true);
    }

    public static void doLAF() {
        LookAndFeel swinglaf = UIManager.getLookAndFeel();
        A03LookAndFeel a03laf = new A03LookAndFeel();
        try {
            guiConf = Resource.getInstance().getSystem().getProperty("gui.pref").toString();
            if (guiConf.equalsIgnoreCase("a03")) {
                UIManager.setLookAndFeel(a03laf);
            } else if (guiConf.equalsIgnoreCase("swing")) {
                a03laf.uninitialize();
                UIManager.setLookAndFeel(swinglaf);
            } else {
                UIManager.setLookAndFeel(a03laf);
            }
        } catch (UnsupportedLookAndFeelException ex) {
            ex.printStackTrace();
        }
    }

    /**
     * @return the login
     */
    public static LoginDialog getLogin() {
        return login;
    }

    /**
     * @param aLogin the login to set
     */
    public static void setLogin(LoginDialog aLogin) {
        login = aLogin;
    }

    /**
     * @return the isLocked
     */
    public static boolean isIsLocked() {
        return isLocked;
    }

    /**
     * @param aIsLocked the isLocked to set
     */
    public static void setIsLocked(boolean aIsLocked) {
        isLocked = aIsLocked;
    }

    /**
     * @return the mf
     */
    public MainFrame getMf() {
        return mf;
    }

    /**
     * @param aMf the mf to set
     */
    public void setMf(MainFrame aMf) {
        mf = aMf;
    }
}
